/**
 * Created by hejg on 2018/5/7.
 */
import React, {Component} from 'react';
import {
    View,
    StyleSheet, Platform,
    Text, WebView, StatusBar, AsyncStorage
} from 'react-native';
import Feather from 'react-native-vector-icons/Feather';
import Header from '../../components/Header';
import Style from '../../components/Style';
import Tool from '../../components/Tool';

export default class SpecialScreen extends Component {
    static navigationOptions = {
        // title: 'Lots of features here',
        header: null,
        tabBarIcon: ({focused, tintColor}) => {
            return <Feather name={`grid${focused ? '' : ''}`} size={20} color={Style.color.red} style={{marginTop:2}}/>;
        },
        tabBarLabel: '专题'
    };

    constructor(props) {
        super(props);
        this.state = {
            lastLoginToken: ''
        }
    }

    componentDidMount() {
        AsyncStorage.getItem(Tool.storageConst.userKey, (err, result) => {
            if (result) {
                this.setState({lastLoginToken: JSON.parse(result).lastLoginToken});
            }
        });
        this._navListener = this.props.navigation.addListener('didFocus', () => {
            Platform.OS === 'android' && StatusBar.setBackgroundColor('#A2BBDA');//#A2BBDA #BBA2D2
        });
    }

    componentWillUnmount() {
        this._navListener.remove();
    }

    render() {
        return (
            <View style={styles.container}>
                {/*<Header headerTitle="专题" headerLeft={<View/>}/>*/}
                {/*<StatusBar backgroundColor={this.state.barBackgroundColor} barStyle="light-content"/>*/}
                {
                    this.state.lastLoginToken ? <WebView style={{flex:1}}
                                                         startInLoadingState={true}
                                                         source={{uri:Tool.appPath.mobile+'integrate.html?token='+this.state.lastLoginToken}}/>
                        :
                        null
                }
            </View>
        );
    }

    _showMoreApp = () => {
        this.props.navigation.navigate('Home');
    };
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: Style.color.screen
    },
});